#!/usr/bin/env python

import os

env = {}
Import("env")
Import("ssl")

env["target_path"] = "../" + env["target_path"]

if not os.path.isdir(env["target_path"]):
    os.mkdir(env["target_path"])

# Check our platform specifics
env["target_path"] += env["platform"] + "/"

if env["platform"] == "macos":
    if env["macos_deployment_target"] != "default":
        env.Append(CCFLAGS=["-mmacosx-version-min=" +
                            env["macos_deployment_target"]])
        env.Append(LINKFLAGS=["-mmacosx-version-min=" +
                              env["macos_deployment_target"]])
elif env["platform"] == "windows":
    env.Append(LIBS=["advapi32", "winhttp", "rpcrt4", "crypt32",
               "ole32", "user32", "wsock32", "ws2_32", "bcrypt"])

env.Append(CPPPATH=[".", "src/"])

env.Append(CPPPATH=["#thirdparty/git2/libgit2/include/"])

lib_sources = Glob("src/*.cpp")
env.Depends(lib_sources, ssl)
library = env.SharedLibrary(
    target=env["target_path"] +
    "{}{}{}".format(env["target_name"], env["suffix"], env["SHLIBSUFFIX"]),
    source=lib_sources
)
Default(library)
